package org.changwang.List;

import java.util.List;

/**
 * @ClassName ListAddUse
 * @Description
 * @Author c.w
 * @Date 2025/6/18 18:18
 * @Version 1.0.0
 */
public class ListAddUse {

	public static void main(String[] args) {
		add();
	}

	public static List<User> initList() {
		User user = new User("1", "1", 29);
		User user1 = new User("2", "2", 29);
		User user2 = new User("3", "3", 29);
		User user3 = new User("4", "4", 29);
		List<User> list = new java.util.ArrayList<>();
		list.add(user);
		list.add(user1);
		list.add(user2);
		list.add(user3);

		return list;
	}

	public static void printList(List<User> list){
		for (int i = 0; i < list.size(); i++) {
			System.out.println(i+"------"+list.get(i));
		}
	}

	public static void add() {
		List<User> userList = new java.util.ArrayList<>(initList());
		userList.add(new User("5", "5", 29));
		printList(userList);
		System.out.println("=====================");
		userList.add(3,new User("6", "6", 29));
		printList(userList);

	}
}